package o;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources.Theme;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable.ConstantState;
import android.graphics.drawable.LayerDrawable;
import android.os.Build.VERSION;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import java.lang.ref.WeakReference;
import java.util.WeakHashMap;
import org.xmlpull.v1.XmlPullParser;

@RestrictTo({androidx.annotation.RestrictTo.d.ˊ})
public final class bx {
    private static final int[] ʼ = new int[]{o.ah.d.ʼॱ, o.ah.d.ᐝ, o.ah.d.ᐝॱ};
    private static final int[] ʽ = new int[]{o.ah.d.ˏˏ, o.ah.d.ॱʼ, o.ah.d.ʻ, o.ah.d.ˌ, o.ah.d.ˋˋ, o.ah.d.ˑ, o.ah.d.ͺॱ, o.ah.d.ˎˎ, o.ah.d.ˏˎ, o.ah.d.ˎˏ};
    private static final d ˊ = new d(6);
    private static final Mode ˋ = Mode.SRC_IN;
    private static final int[] ˎ = new int[]{o.ah.d.ـ, o.ah.d.ॱʽ, o.ah.d.ˋ};
    private static bx ˏ;
    private static final int[] ॱ = new int[]{o.ah.d.ˏॱ, o.ah.d.ˉ, o.ah.d.ॱˋ, o.ah.d.ˊॱ, o.ah.d.ॱˊ, o.ah.d.ʻॱ, o.ah.d.ॱᐝ};
    private static final int[] ॱॱ = new int[]{o.ah.d.ˍ, o.ah.d.ॱͺ};
    private static final int[] ᐝ = new int[]{o.ah.d.ˊ, o.ah.d.ʽ};
    private WeakHashMap<Context, dz<ColorStateList>> ʻ;
    private final WeakHashMap<Context, dw<WeakReference<ConstantState>>> ˊॱ = new WeakHashMap(0);
    private dz<String> ˋॱ;
    private TypedValue ˏॱ;
    private boolean ͺ;
    private ds<String, e> ॱˊ;

    interface e {
        Drawable ˎ(@NonNull Context context, @NonNull XmlPullParser xmlPullParser, @NonNull AttributeSet attributeSet, @Nullable Theme theme);
    }

    static class a implements e {
        a() {
        }

        public Drawable ˎ(@NonNull Context context, @NonNull XmlPullParser xmlPullParser, @NonNull AttributeSet attributeSet, @Nullable Theme theme) {
            try {
                return ot.ˊ(context, context.getResources(), xmlPullParser, attributeSet, theme);
            } catch (Throwable e) {
                Log.e("AvdcInflateDelegate", "Exception while inflating <animated-vector>", e);
                return null;
            }
        }
    }

    @RequiresApi(11)
    static class b implements e {
        b() {
        }

        public Drawable ˎ(@NonNull Context context, @NonNull XmlPullParser xmlPullParser, @NonNull AttributeSet attributeSet, @Nullable Theme theme) {
            try {
                return ap.ˊ(context, context.getResources(), xmlPullParser, attributeSet, theme);
            } catch (Throwable e) {
                Log.e("AsldcInflateDelegate", "Exception while inflating <animated-selector>", e);
                return null;
            }
        }
    }

    static class c implements e {
        c() {
        }

        public Drawable ˎ(@NonNull Context context, @NonNull XmlPullParser xmlPullParser, @NonNull AttributeSet attributeSet, @Nullable Theme theme) {
            try {
                return ov.ॱ(context.getResources(), xmlPullParser, attributeSet, theme);
            } catch (Throwable e) {
                Log.e("VdcInflateDelegate", "Exception while inflating <vector>", e);
                return null;
            }
        }
    }

    static class d extends dx<Integer, PorterDuffColorFilter> {
        public d(int i) {
            super(i);
        }

        PorterDuffColorFilter ˊ(int i, Mode mode) {
            return (PorterDuffColorFilter) ˏ(Integer.valueOf(ॱ(i, mode)));
        }

        PorterDuffColorFilter ˎ(int i, Mode mode, PorterDuffColorFilter porterDuffColorFilter) {
            return (PorterDuffColorFilter) ˋ(Integer.valueOf(ॱ(i, mode)), porterDuffColorFilter);
        }

        private static int ॱ(int i, Mode mode) {
            return ((i + 31) * 31) + mode.hashCode();
        }
    }

    public static synchronized bx ˋ() {
        bx bxVar;
        synchronized (bx.class) {
            if (ˏ == null) {
                ˏ = new bx();
                ˋ(ˏ);
            }
            bxVar = ˏ;
        }
        return bxVar;
    }

    private static void ˋ(@NonNull bx bxVar) {
        if (VERSION.SDK_INT < 24) {
            bxVar.ˊ("vector", new c());
            bxVar.ˊ("animated-vector", new a());
            bxVar.ˊ("animated-selector", new b());
        }
    }

    public synchronized Drawable ˎ(@NonNull Context context, @DrawableRes int i) {
        return ˋ(context, i, false);
    }

    synchronized Drawable ˋ(@NonNull Context context, @DrawableRes int i, boolean z) {
        Drawable ॱ;
        ʼ(context);
        ॱ = ॱ(context, i);
        if (ॱ == null) {
            ॱ = ˏ(context, i);
        }
        if (ॱ == null) {
            ॱ = fo.ˊ(context, i);
        }
        if (ॱ != null) {
            ॱ = ˏ(context, i, z, ॱ);
        }
        if (ॱ != null) {
            cl.ˎ(ॱ);
        }
        return ॱ;
    }

    public synchronized void ˏ(@NonNull Context context) {
        dw dwVar = (dw) this.ˊॱ.get(context);
        if (dwVar != null) {
            dwVar.ˊ();
        }
    }

    private static long ॱ(TypedValue typedValue) {
        return (((long) typedValue.assetCookie) << 32) | ((long) typedValue.data);
    }

    private Drawable ˏ(@NonNull Context context, @DrawableRes int i) {
        if (this.ˏॱ == null) {
            this.ˏॱ = new TypedValue();
        }
        TypedValue typedValue = this.ˏॱ;
        context.getResources().getValue(i, typedValue, true);
        long ॱ = ॱ(typedValue);
        Drawable ॱ2 = ॱ(context, ॱ);
        if (ॱ2 == null) {
            if (i == o.ah.d.ʼ) {
                ॱ2 = new LayerDrawable(new Drawable[]{ˎ(context, o.ah.d.ᐝ), ˎ(context, o.ah.d.ʻ)});
            }
            if (ॱ2 != null) {
                ॱ2.setChangingConfigurations(typedValue.changingConfigurations);
                ˊ(context, ॱ, ॱ2);
            }
        }
        return ॱ2;
    }

    private Drawable ˏ(@NonNull Context context, @DrawableRes int i, boolean z, @NonNull Drawable drawable) {
        ColorStateList ˋ = ˋ(context, i);
        if (ˋ != null) {
            if (cl.ˋ(drawable)) {
                drawable = drawable.mutate();
            }
            drawable = gg.ʻ(drawable);
            gg.ॱ(drawable, ˋ);
            Mode ˎ = ˎ(i);
            if (ˎ == null) {
                return drawable;
            }
            gg.ˋ(drawable, ˎ);
            return drawable;
        } else if (i == o.ah.d.ˊˋ) {
            r0 = (LayerDrawable) drawable;
            ˎ(r0.findDrawableByLayerId(16908288), cs.ˊ(context, o.ah.c.ʾ), ˋ);
            ˎ(r0.findDrawableByLayerId(16908303), cs.ˊ(context, o.ah.c.ʾ), ˋ);
            ˎ(r0.findDrawableByLayerId(16908301), cs.ˊ(context, o.ah.c.ˈ), ˋ);
            return drawable;
        } else if (i == o.ah.d.ʾ || i == o.ah.d.ʿ || i == o.ah.d.ˈ) {
            r0 = (LayerDrawable) drawable;
            ˎ(r0.findDrawableByLayerId(16908288), cs.ॱ(context, o.ah.c.ʾ), ˋ);
            ˎ(r0.findDrawableByLayerId(16908303), cs.ˊ(context, o.ah.c.ˈ), ˋ);
            ˎ(r0.findDrawableByLayerId(16908301), cs.ˊ(context, o.ah.c.ˈ), ˋ);
            return drawable;
        } else if (ˏ(context, i, drawable) || !z) {
            return drawable;
        } else {
            return null;
        }
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private android.graphics.drawable.Drawable ॱ(@androidx.annotation.NonNull android.content.Context r10, @androidx.annotation.DrawableRes int r11) {
        /*
        r9 = this;
        r1 = 0;
        r8 = 2;
        r7 = 1;
        r0 = r9.ॱˊ;
        if (r0 == 0) goto L_0x00bf;
    L_0x0007:
        r0 = r9.ॱˊ;
        r0 = r0.isEmpty();
        if (r0 != 0) goto L_0x00bf;
    L_0x000f:
        r0 = r9.ˋॱ;
        if (r0 == 0) goto L_0x002f;
    L_0x0013:
        r0 = r9.ˋॱ;
        r0 = r0.ˊ(r11);
        r0 = (java.lang.String) r0;
        r2 = "appcompat_skip_skip";
        r2 = r2.equals(r0);
        if (r2 != 0) goto L_0x002d;
    L_0x0023:
        if (r0 == 0) goto L_0x0036;
    L_0x0025:
        r2 = r9.ॱˊ;
        r0 = r2.get(r0);
        if (r0 != 0) goto L_0x0036;
    L_0x002d:
        r0 = r1;
    L_0x002e:
        return r0;
    L_0x002f:
        r0 = new o.dz;
        r0.<init>();
        r9.ˋॱ = r0;
    L_0x0036:
        r0 = r9.ˏॱ;
        if (r0 != 0) goto L_0x0041;
    L_0x003a:
        r0 = new android.util.TypedValue;
        r0.<init>();
        r9.ˏॱ = r0;
    L_0x0041:
        r2 = r9.ˏॱ;
        r0 = r10.getResources();
        r0.getValue(r11, r2, r7);
        r4 = ॱ(r2);
        r1 = r9.ॱ(r10, r4);
        if (r1 == 0) goto L_0x0056;
    L_0x0054:
        r0 = r1;
        goto L_0x002e;
    L_0x0056:
        r3 = r2.string;
        if (r3 == 0) goto L_0x008a;
    L_0x005a:
        r3 = r2.string;
        r3 = r3.toString();
        r6 = ".xml";
        r3 = r3.endsWith(r6);
        if (r3 == 0) goto L_0x008a;
    L_0x0068:
        r3 = r0.getXml(r11);	 Catch:{ Exception -> 0x0082 }
        r6 = android.util.Xml.asAttributeSet(r3);	 Catch:{ Exception -> 0x0082 }
    L_0x0070:
        r0 = r3.next();	 Catch:{ Exception -> 0x0082 }
        if (r0 == r8) goto L_0x0078;
    L_0x0076:
        if (r0 != r7) goto L_0x0070;
    L_0x0078:
        if (r0 == r8) goto L_0x0095;
    L_0x007a:
        r0 = new org.xmlpull.v1.XmlPullParserException;	 Catch:{ Exception -> 0x0082 }
        r2 = "No start tag found";
        r0.<init>(r2);	 Catch:{ Exception -> 0x0082 }
        throw r0;	 Catch:{ Exception -> 0x0082 }
    L_0x0082:
        r0 = move-exception;
        r2 = "AppCompatDrawableManag";
        r3 = "Exception while inflating drawable";
        android.util.Log.e(r2, r3, r0);
    L_0x008a:
        r0 = r1;
    L_0x008b:
        if (r0 != 0) goto L_0x002e;
    L_0x008d:
        r1 = r9.ˋॱ;
        r2 = "appcompat_skip_skip";
        r1.ˏ(r11, r2);
        goto L_0x002e;
    L_0x0095:
        r0 = r3.getName();	 Catch:{ Exception -> 0x0082 }
        r7 = r9.ˋॱ;	 Catch:{ Exception -> 0x0082 }
        r7.ˏ(r11, r0);	 Catch:{ Exception -> 0x0082 }
        r7 = r9.ॱˊ;	 Catch:{ Exception -> 0x0082 }
        r0 = r7.get(r0);	 Catch:{ Exception -> 0x0082 }
        r0 = (o.bx.e) r0;	 Catch:{ Exception -> 0x0082 }
        if (r0 == 0) goto L_0x00b0;
    L_0x00a8:
        r7 = r10.getTheme();	 Catch:{ Exception -> 0x0082 }
        r1 = r0.ˎ(r10, r3, r6, r7);	 Catch:{ Exception -> 0x0082 }
    L_0x00b0:
        if (r1 == 0) goto L_0x00bd;
    L_0x00b2:
        r0 = r2.changingConfigurations;	 Catch:{ Exception -> 0x0082 }
        r1.setChangingConfigurations(r0);	 Catch:{ Exception -> 0x0082 }
        r0 = r9.ˊ(r10, r4, r1);	 Catch:{ Exception -> 0x0082 }
        if (r0 == 0) goto L_0x00bd;
    L_0x00bd:
        r0 = r1;
        goto L_0x008b;
    L_0x00bf:
        r0 = r1;
        goto L_0x002e;
        */
        throw new UnsupportedOperationException("Method not decompiled: o.bx.ॱ(android.content.Context, int):android.graphics.drawable.Drawable");
    }

    private synchronized Drawable ॱ(@NonNull Context context, long j) {
        Drawable drawable;
        dw dwVar = (dw) this.ˊॱ.get(context);
        if (dwVar == null) {
            drawable = null;
        } else {
            WeakReference weakReference = (WeakReference) dwVar.ˋ(j);
            if (weakReference != null) {
                ConstantState constantState = (ConstantState) weakReference.get();
                if (constantState != null) {
                    drawable = constantState.newDrawable(context.getResources());
                } else {
                    dwVar.ॱ(j);
                }
            }
            drawable = null;
        }
        return drawable;
    }

    private synchronized boolean ˊ(@NonNull Context context, long j, @NonNull Drawable drawable) {
        boolean z;
        ConstantState constantState = drawable.getConstantState();
        if (constantState != null) {
            dw dwVar = (dw) this.ˊॱ.get(context);
            if (dwVar == null) {
                dwVar = new dw();
                this.ˊॱ.put(context, dwVar);
            }
            dwVar.ˎ(j, new WeakReference(constantState));
            z = true;
        } else {
            z = false;
        }
        return z;
    }

    synchronized Drawable ˏ(@NonNull Context context, @NonNull dd ddVar, @DrawableRes int i) {
        Drawable ॱ;
        ॱ = ॱ(context, i);
        if (ॱ == null) {
            ॱ = ddVar.ˏ(i);
        }
        if (ॱ != null) {
            ॱ = ˏ(context, i, false, ॱ);
        } else {
            ॱ = null;
        }
        return ॱ;
    }

    static boolean ˏ(@NonNull Context context, @DrawableRes int i, @NonNull Drawable drawable) {
        int i2;
        Mode mode;
        boolean z;
        int i3;
        Mode mode2 = ˋ;
        if (ˋ(ˎ, i)) {
            i2 = o.ah.c.ʾ;
            mode = mode2;
            z = true;
            i3 = -1;
        } else if (ˋ(ʽ, i)) {
            i2 = o.ah.c.ˈ;
            mode = mode2;
            z = true;
            i3 = -1;
        } else if (ˋ(ʼ, i)) {
            z = true;
            mode = Mode.MULTIPLY;
            i2 = 16842801;
            i3 = -1;
        } else if (i == o.ah.d.ॱˎ) {
            i2 = 16842800;
            i3 = Math.round(40.8f);
            mode = mode2;
            z = true;
        } else if (i == o.ah.d.ॱॱ) {
            i2 = 16842801;
            mode = mode2;
            z = true;
            i3 = -1;
        } else {
            i3 = -1;
            i2 = 0;
            mode = mode2;
            z = false;
        }
        if (!z) {
            return false;
        }
        if (cl.ˋ(drawable)) {
            drawable = drawable.mutate();
        }
        drawable.setColorFilter(ॱ(cs.ˊ(context, i2), mode));
        if (i3 == -1) {
            return true;
        }
        drawable.setAlpha(i3);
        return true;
    }

    private void ˊ(@NonNull String str, @NonNull e eVar) {
        if (this.ॱˊ == null) {
            this.ॱˊ = new ds();
        }
        this.ॱˊ.put(str, eVar);
    }

    private static boolean ˋ(int[] iArr, int i) {
        for (int i2 : iArr) {
            if (i2 == i) {
                return true;
            }
        }
        return false;
    }

    static Mode ˎ(int i) {
        if (i == o.ah.d.ˊˊ) {
            return Mode.MULTIPLY;
        }
        return null;
    }

    synchronized ColorStateList ˋ(@NonNull Context context, @DrawableRes int i) {
        ColorStateList ˊ;
        ˊ = ˊ(context, i);
        if (ˊ == null) {
            if (i == o.ah.d.ͺ) {
                ˊ = ar.ˊ(context, o.ah.a.ˏ);
            } else if (i == o.ah.d.ˋᐝ) {
                ˊ = ar.ˊ(context, o.ah.a.ʽ);
            } else if (i == o.ah.d.ˊˊ) {
                ˊ = ॱ(context);
            } else if (i == o.ah.d.ˏ) {
                ˊ = ˎ(context);
            } else if (i == o.ah.d.ॱ) {
                ˊ = ˊ(context);
            } else if (i == o.ah.d.ˎ) {
                ˊ = ˋ(context);
            } else if (i == o.ah.d.ˊᐝ || i == o.ah.d.ˋˊ) {
                ˊ = ar.ˊ(context, o.ah.a.ॱॱ);
            } else if (ˋ(ॱ, i)) {
                ˊ = cs.ˏ(context, o.ah.c.ʾ);
            } else if (ˋ(ॱॱ, i)) {
                ˊ = ar.ˊ(context, o.ah.a.ˋ);
            } else if (ˋ(ᐝ, i)) {
                ˊ = ar.ˊ(context, o.ah.a.ˎ);
            } else if (i == o.ah.d.ʽॱ) {
                ˊ = ar.ˊ(context, o.ah.a.ॱ);
            }
            if (ˊ != null) {
                ˏ(context, i, ˊ);
            }
        }
        return ˊ;
    }

    private ColorStateList ˊ(@NonNull Context context, @DrawableRes int i) {
        if (this.ʻ == null) {
            return null;
        }
        dz dzVar = (dz) this.ʻ.get(context);
        if (dzVar != null) {
            return (ColorStateList) dzVar.ˊ(i);
        }
        return null;
    }

    private void ˏ(@NonNull Context context, @DrawableRes int i, @NonNull ColorStateList colorStateList) {
        if (this.ʻ == null) {
            this.ʻ = new WeakHashMap();
        }
        dz dzVar = (dz) this.ʻ.get(context);
        if (dzVar == null) {
            dzVar = new dz();
            this.ʻ.put(context, dzVar);
        }
        dzVar.ˏ(i, colorStateList);
    }

    private ColorStateList ˎ(@NonNull Context context) {
        return ʼ(context, cs.ˊ(context, o.ah.c.ʿ));
    }

    private ColorStateList ˊ(@NonNull Context context) {
        return ʼ(context, 0);
    }

    private ColorStateList ˋ(@NonNull Context context) {
        return ʼ(context, cs.ˊ(context, o.ah.c.ॱˋ));
    }

    private ColorStateList ʼ(@NonNull Context context, @ColorInt int i) {
        r0 = new int[4][];
        r1 = new int[4];
        int ˊ = cs.ˊ(context, o.ah.c.ʼॱ);
        int ॱ = cs.ॱ(context, o.ah.c.ʿ);
        r0[0] = cs.ˊ;
        r1[0] = ॱ;
        r0[1] = cs.ˎ;
        r1[1] = fu.ˎ(ˊ, i);
        r0[2] = cs.ˏ;
        r1[2] = fu.ˎ(ˊ, i);
        r0[3] = cs.ᐝ;
        r1[3] = i;
        return new ColorStateList(r0, r1);
    }

    private ColorStateList ॱ(Context context) {
        int[][] iArr = new int[3][];
        int[] iArr2 = new int[3];
        ColorStateList ˏ = cs.ˏ(context, o.ah.c.ˊˊ);
        if (ˏ == null || !ˏ.isStateful()) {
            iArr[0] = cs.ˊ;
            iArr2[0] = cs.ॱ(context, o.ah.c.ˊˊ);
            iArr[1] = cs.ॱ;
            iArr2[1] = cs.ˊ(context, o.ah.c.ˈ);
            iArr[2] = cs.ᐝ;
            iArr2[2] = cs.ˊ(context, o.ah.c.ˊˊ);
        } else {
            iArr[0] = cs.ˊ;
            iArr2[0] = ˏ.getColorForState(iArr[0], 0);
            iArr[1] = cs.ॱ;
            iArr2[1] = cs.ˊ(context, o.ah.c.ˈ);
            iArr[2] = cs.ᐝ;
            iArr2[2] = ˏ.getDefaultColor();
        }
        return new ColorStateList(iArr, iArr2);
    }

    static void ˏ(Drawable drawable, cu cuVar, int[] iArr) {
        if (!cl.ˋ(drawable) || drawable.mutate() == drawable) {
            if (cuVar.ˎ || cuVar.ˊ) {
                drawable.setColorFilter(ˋ(cuVar.ˎ ? cuVar.ˋ : null, cuVar.ˊ ? cuVar.ˏ : ˋ, iArr));
            } else {
                drawable.clearColorFilter();
            }
            if (VERSION.SDK_INT <= 23) {
                drawable.invalidateSelf();
                return;
            }
            return;
        }
        Log.d("AppCompatDrawableManag", "Mutated drawable is not the same instance as the input.");
    }

    private static PorterDuffColorFilter ˋ(ColorStateList colorStateList, Mode mode, int[] iArr) {
        if (colorStateList == null || mode == null) {
            return null;
        }
        return ॱ(colorStateList.getColorForState(iArr, 0), mode);
    }

    public static synchronized PorterDuffColorFilter ॱ(int i, Mode mode) {
        PorterDuffColorFilter ˊ;
        synchronized (bx.class) {
            ˊ = ˊ.ˊ(i, mode);
            if (ˊ == null) {
                ˊ = new PorterDuffColorFilter(i, mode);
                ˊ.ˎ(i, mode, ˊ);
            }
        }
        return ˊ;
    }

    private static void ˎ(Drawable drawable, int i, Mode mode) {
        if (cl.ˋ(drawable)) {
            drawable = drawable.mutate();
        }
        if (mode == null) {
            mode = ˋ;
        }
        drawable.setColorFilter(ॱ(i, mode));
    }

    private void ʼ(@NonNull Context context) {
        if (!this.ͺ) {
            this.ͺ = true;
            Drawable ˎ = ˎ(context, o.ah.d.ॱʻ);
            if (ˎ == null || !ˊ(ˎ)) {
                this.ͺ = false;
                throw new IllegalStateException("This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat.");
            }
        }
    }

    private static boolean ˊ(@NonNull Drawable drawable) {
        return (drawable instanceof ov) || "android.graphics.drawable.VectorDrawable".equals(drawable.getClass().getName());
    }
}
